package org.winplus.sh;




import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageButton;
import android.widget.TextView;





public class RecordAdapter extends BaseAdapter{
	
	private Context cxt=null; 
	Boolean flag = true;
	Holder holder = null; 
	
	//数据源
	 private String[] data = {};
	 private String[] data1 = {};
	 private String[] data2 = {};
	 public RecordAdapter(Context context) {
		// TODO Auto-generated constructor stub
		cxt=context;
	}

	 public RecordAdapter(Context context, String[] data ,String [] time,String [] time_length) {
			// TODO Auto-generated constructor stub
			cxt=context;
			this.data1 = data;
			this.data=time;
			this.data2=time_length;
		}
	
	 
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return data.length;
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
//		return arraylist.get(position);
		return data[position];
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}
	
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		
		// TODO Auto-generated method stub
		if (convertView==null) {
			holder=new Holder();
			LayoutInflater inflater=LayoutInflater.from(cxt);
			//引用外部xml文件listview_item设置listview item的外观
			convertView=inflater.inflate(R.layout.listview_item, null);
			
			//根据控件id将相应控件添加到converview上
			holder.tv1=(TextView) convertView.findViewById(R.id.tv1);
			holder.tv2=(TextView) convertView.findViewById(R.id.tv2);
			holder.tv3=(TextView) convertView.findViewById(R.id.tv3);
			convertView.setTag(holder);
		}
		holder = (Holder) convertView.getTag();
		//设置tv1,tv2,tv3的内容
		holder.tv1.setText(data[position]);
		holder.tv2.setText(data1[position]);
		holder.tv3.setText(data2[position]);
		
		
		// int temp = position;
		return convertView;
	}
	
	//创建holder，减少findviewbyid的调用
	static class Holder{
		TextView tv1,tv2,tv3;
		ImageButton buth1;
		ImageButton buth2;
	}
}